package in.indijava.scjp5questions;

/**
 * @author oguzhan.blogspot.com
 * */
public class StaticInstanceBlocksRunOrder {

	static {
		System.out.println("FIRST STATIC BLOCK-StaticInstanceBlocksRunOrder");
	}
	
	static class A {
		static {
			System.out.println("FIRST STATIC BLOCK-A");
		}
		
		{ 
			System.out.println("FIRST INSTANCE BLOCK-A");
		}
		
		public A() {
			System.out.println("CONSTRUCTOR-A");
		}
		
		static { 
			System.out.println("SECOND STATIC BLOCK-A");
		}
		
		{ 
			System.out.println("SECOND INSTANCE BLOCK-A");
		}
	}
	
	static class B extends A{
		static {
			System.out.println("FIRST STATIC BLOCK-B");
		}
		
		{ 
			System.out.println("FIRST INSTANCE BLOCK-B");
		}
		
		public B() {
			System.out.println("CONSTRUCTOR-B");
		}
		
		static { 
			System.out.println("SECOND STATIC BLOCK-B");
		}
		
		{ 
			System.out.println("SECOND INSTANCE BLOCK-B");
		}
		
		static void any() {
			System.out.println("ANY METHOD IS RUN!");
		}
	}
	
	public static void main(String[] args) {
		System.out.println("MAIN STARTED");
//		B.any();
		A a = new B();
		System.out.println(a);
	}
	
	static {
		System.out.println("SECOND STATIC BLOCK-StaticInstanceBlocksRunOrder");
	}
}
